<html>
<!-- =====================================================================

  File:      usp_CustomerAddSurvey.htm for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
    <head>
        <title>Adventure Works Cycles Store Documentation</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <h1>"usp_CustomerAddSurvey" Stored Procedure</h1>

        <b>Description:</b>

        <P>This is a simple stored procedure that takes a customer id, and an XML document as a string and stores it into
        the Demographics column of the appropriate row in the Individual table.  This XML document must conform
        to the individual survey schema defined by the AdventureWorks database.</P>

        <b>Definition:</b>

<pre style="background-color:white">
<span style="color: #0000FF"><strong>CREATE</strong></span> PROCEDURE usp_CustomerAddSurvey
<span style="color: #4444FF">(</span>
	@CustomerID <span style="color: #2040a0"><strong>int</strong></span><span style="color: #4444FF">,</span>
	@CustomerSurvey <span style="color: #2040a0"><strong>nvarchar</strong></span><span style="color: #4444FF">(</span>2048<span style="color: #4444FF">)</span>
<span style="color: #4444FF">)</span>
WITH EXECUTE <span style="color: #0000FF"><strong>AS</strong></span> OWNER
<span style="color: #0000FF"><strong>AS</strong></span>

UPDATE Sales.Individual
<span style="color: #008000">-- Find the five most common additional products purchased along with a given product.</span>
<span style="color: #0000FF"><strong>SET</strong></span> Demographics <span style="color: #4444FF">=</span> @CustomerSurvey
<span style="color: #0000FF"><strong>WHERE</strong></span> CustomerID <span style="color: #4444FF">=</span> @CustomerID;

</pre>

        <b>Database Tables Used: </b>

        <P><i>Individual:</i> &nbsp;The Individual table keeps track of retail customers.  It contains the link between
        the Customer table and the Contact table for people who buy products on the web site.
        </P>
        
        <P>
        <img src="1x1.gif" width=25> <IMG src="../docs/images/Individual.gif" width="153" height="119">
        </P>

    </body>
</html>
